< previous page page_220 next page >

Page 220
When asking the user a question, you should keep the question short and simple. In the preceding code, MsgBox is used as a function call to retrieve the clicked button. You can see that Im comparing the value returned against the constant vbYes. Several constants are used to determine which button has been clicked in a MsgBox (see Table 11.3).
Table 11.3 Constants That Tell Which Button Was Clicked.
ConstantDescription
vbAbortThe Abort button was clicked.
vbCancelThe Cancel button was clicked.
vbIgnoreThe Ignore button was clicked.
vbNoThe No button was clicked.
vbOKThe OK button was clicked.
vbRetryThe Retry button was clicked.
vbYesThe Yes button was clicked.

If you think the user might need more help with a particular dialog box, you should add a Help context ID and Help file to the parameters you pass to the MsgBox dialog box. To add the Help button to the MsgBox, use the following code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdHelp_Click()
   MsgBox "A Critical Error Has Occurred", _
                vbCritical + vbAbortRetryIgnore _
                + vbMsgBoxHelpButton, _
                "Error", App.Path & "\MyHelp.hlp", 5
End Sub
When you click the fourth command button in the form, youll see the message box shown in Figure 11.4.
8160-0220a.gif
Figure 11.4
A message box with a Help button.

 
< previous page page_220 next page >

If you like this book, buy it!